package com.rightsidetech.http.controller.agentApp.file;

import com.aliyun.oss.OSS;
import com.rightsidetech.commom.base.ResponseData;
import com.rightsidetech.commom.config.AliyunOSSConfig;
import com.rightsidetech.commom.utils.UplodeUtils;
import com.rightsidetech.http.aspect.Log;
import com.rightsidetech.http.aspect.Token;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.shenyu.client.dubbo.common.annotation.ShenyuDubboClient;
import org.apache.shenyu.client.springmvc.annotation.ShenyuSpringMvcClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

/**
 * @Author: yhr
 * @Date: 2021-11-08 16:20
 */
@RestController
@RequestMapping("/agentApp/file")
@ShenyuSpringMvcClient(path = "/agentApp/file/**")
@Api(tags = "文件上传")
public class AgentOSSController {
    @Autowired
    private OSS ossClient;

    @Autowired
    private AliyunOSSConfig aliyunOSSConfig;

    @Log
    @Token
    @PostMapping("/more_uplode")
    @ApiOperation("图片上传")
    public ResponseData<String[]> moreUplode(MultipartFile[] files) throws Exception {
        if (null == files || files.length == 0) {
            return ResponseData.fail("文件不能为空");
        }

        return UplodeUtils.adminMoreUplode(files,ossClient, aliyunOSSConfig);
    }
}
